﻿//页面初始化
$(document).ready(function(){
	initPage();	
});

function initPage() {

	////console.debug("initPage=======");
//修改商品信息 为提交按钮添加动作
	$('#form_edit').submit(function(){
		var TXT_NETBUSY = "\u7f51\u7edc\u7e41\u5fd9\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5\u2026";
		var TXT_NETWAIT = "\u6b63\u5728\u83b7\u53d6\u6570\u636e\uff0c\u8bf7\u7a0d\u5019\u2026";
		var TXT_POSTDATA = "\u6b63\u5728\u63d0\u4ea4\u6570\u636e\uff0c\u8bf7\u7a0d\u5019\u2026";
		
		//console.debug("initPage===111111111====");
		var form = $(this);
		var msg = $("#result");
		var data = form.serializeArray();
		msg.warning(TXT_POSTDATA);
		form.disabled();
		$.ajax({
			type: "POST",
			url: form.attr("action")+"?act=edit",
			data: data,
			dataType: "json",
			success: function(ret){
				//console.debug("initPage==ret=="+ret.msg);
				msg.warning(ret.msg);		
				if (ret.success) {
					var d = ret.url ? ret.url : "/";
					setTimeout( function() {			
						window.location = d;
					}, 1000)
				} else {
					setTimeout( function() {
						msg.warning('');		
						form.enabled();
					}, 1000)
				
				}				
			},
			error: function(res){
				alert("error");
				msg.warning(TXT_NETBUSY);
				form.enabled();
			}
		});
		return false;
	});
}//end initPage